#ifndef CLIENT_H
#define CLIENT_H
#include <QTcpSocket>
#include <QDir>
#include <QFile>
#include <QHostAddress>
#include <QObject>
#include "pack.h"
class myClient:public QObject
{
    Q_OBJECT
public:

    Pack readed_pack;// 暂存已读部分的协议包
    int readed_pack_size = 0;// 记录已读协议包的大小
    int unreaded_pack_size = 0; // 记录未读协议包的大小

    int readed_size = 0;
    int readed_size_size = 0;
    int unreaded_size_size = 0;



    myClient(QTcpSocket* client);
    QHostAddress peerAddress() const;
    quint16 peerPort() const;
    qint64 read(char *data, qint64 maxSize);
    qint64 write(const char *data, qint64 maxSize);

    void setName(const QString& name);
    void setPath(const QDir& path);
    void setRootpath(const QDir& rootpath);


    QString getName();
    QDir getPath();
    QDir getRootpath();
    QFile* getFile();
    void setFile(const QString& path);
    void delFile();
signals:
    void readyRead();
    void disconnected();
private:
    QTcpSocket* client;
    QString name; // 用来记录当前客户端的用户姓名
    QDir path; // 用来记录当前客户端的观察文件路径
    QDir rootpath;
    QFile* file;


};

#endif // CLIENT_H
